# Include this directory
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})

# Enumerate source files
FILE(GLOB SRC_FILES *.cpp *.inl)
FILE(GLOB INC_FILES *.h)

SET(DEPENDENT_LIBS "")

# IGL and CGAL
IF (LIBIGL_FOUND AND CGAL_FOUND)
    INCLUDE_DIRECTORIES(${LIBIGL_INCLUDE_DIRS})
    ADD_DEFINITIONS(-DWITH_IGL)
    ADD_DEFINITIONS(-DWITH_CGAL)
    LIST(APPEND DEPENDENT_LIBS cgal_wrapper)
    ADD_SUBDIRECTORY(IGL)
    ADD_SUBDIRECTORY(CGAL)
ENDIF (LIBIGL_FOUND AND CGAL_FOUND)

# Shewchuk's Triangle
IF (TRIANGLE_FOUND)
    LIST(APPEND DEPENDENT_LIBS lib_triangle_wrapper)
    ADD_DEFINITIONS(-DWITH_TRIANGLE)
    ADD_SUBDIRECTORY(ShewchukTriangle)
ENDIF (TRIANGLE_FOUND)

# Geogram
IF (GEOGRAM_FOUND)
    INCLUDE_DIRECTORIES(${GEOGRAM_INCLUDE_DIR})
    LIST(APPEND DEPENDENT_LIBS ${GEOGRAM_LIBRARY} lib_geogram_base)
    ADD_DEFINITIONS(-DWITH_GEOGRAM)
    ADD_SUBDIRECTORY(Geogram)
ENDIF (GEOGRAM_FOUND)

ADD_LIBRARY(lib_triangulation SHARED ${SRC_FILES} ${INC_FILES})
SET_TARGET_PROPERTIES(lib_triangulation PROPERTIES OUTPUT_NAME "triangulation")
TARGET_LINK_LIBRARIES(lib_triangulation Mesh ${DEPENDENT_LIBS})

ADD_CUSTOM_TARGET(triangulation DEPENDS lib_triangulation)
